#include "additionnumberfield.h"

AdditionNumberField::AdditionNumberField(QWidget *parent) :
    QLineEdit(parent)
{
    QRegExp regexp("([0-9]{0,2})");
    this->setValidator(new QRegExpValidator(regexp, this));

    connect(this, SIGNAL(textChanged(QString)), this, SLOT(checkIfValid(QString)));
}

void AdditionNumberField::checkIfValid(QString numberInField)
{
    if (numberInField.toInt() > 34)
        this->setStyleSheet("QLineEdit {background-color: red;}");
    else if (numberInField.toInt() == 0) {
        this->clear();
        this->setStyleSheet("QLineEdit {background-color: white;}");
    }
    else
        this->setStyleSheet("QLineEdit {background-color: white;}");
}
